.class public Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;
.super Ljava/lang/Object;
.source "OffsetCurveSetBuilder.java"


# instance fields
.field private cga:Lcom/vividsolutions/jts/algorithm/CGAlgorithms;

.field private curveBuilder:Lcom/vividsolutions/jts/operation/buffer/OffsetCurveBuilder;

.field private curveList:Ljava/util/List;

.field private distance:D

.field private inputGeom:Lcom/vividsolutions/jts/geom/Geometry;


# direct methods
.method public constructor <init>(Lcom/vividsolutions/jts/geom/Geometry;DLcom/vividsolutions/jts/operation/buffer/OffsetCurveBuilder;)V
    .locals 1

    .line 67
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 55
    new-instance v0, Lcom/vividsolutions/jts/algorithm/RobustCGAlgorithms;

    invoke-direct {v0}, Lcom/vividsolutions/jts/algorithm/RobustCGAlgorithms;-><init>()V

    iput-object v0, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->cga:Lcom/vividsolutions/jts/algorithm/CGAlgorithms;

    .line 61
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    iput-object v0, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->curveList:Ljava/util/List;

    .line 68
    iput-object p1, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->inputGeom:Lcom/vividsolutions/jts/geom/Geometry;

    .line 69
    iput-wide p2, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->distance:D

    .line 70
    iput-object p4, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->curveBuilder:Lcom/vividsolutions/jts/operation/buffer/OffsetCurveBuilder;

    return-void
.end method

.method private add(Lcom/vividsolutions/jts/geom/Geometry;)V
    .locals 1

    .line 116
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Geometry;->isEmpty()Z

    move-result v0

    if-eqz v0, :cond_0

    return-void

    .line 118
    :cond_0
    instance-of v0, p1, Lcom/vividsolutions/jts/geom/Polygon;

    if-eqz v0, :cond_1

    check-cast p1, Lcom/vividsolutions/jts/geom/Polygon;

    invoke-direct {p0, p1}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addPolygon(Lcom/vividsolutions/jts/geom/Polygon;)V

    goto :goto_0

    .line 120
    :cond_1
    instance-of v0, p1, Lcom/vividsolutions/jts/geom/LineString;

    if-eqz v0, :cond_2

    check-cast p1, Lcom/vividsolutions/jts/geom/LineString;

    invoke-direct {p0, p1}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addLineString(Lcom/vividsolutions/jts/geom/LineString;)V

    goto :goto_0

    .line 121
    :cond_2
    instance-of v0, p1, Lcom/vividsolutions/jts/geom/Point;

    if-eqz v0, :cond_3

    check-cast p1, Lcom/vividsolutions/jts/geom/Point;

    invoke-direct {p0, p1}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addPoint(Lcom/vividsolutions/jts/geom/Point;)V

    goto :goto_0

    .line 122
    :cond_3
    instance-of v0, p1, Lcom/vividsolutions/jts/geom/MultiPoint;

    if-eqz v0, :cond_4

    check-cast p1, Lcom/vividsolutions/jts/geom/MultiPoint;

    invoke-direct {p0, p1}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addCollection(Lcom/vividsolutions/jts/geom/GeometryCollection;)V

    goto :goto_0

    .line 123
    :cond_4
    instance-of v0, p1, Lcom/vividsolutions/jts/geom/MultiLineString;

    if-eqz v0, :cond_5

    check-cast p1, Lcom/vividsolutions/jts/geom/MultiLineString;

    invoke-direct {p0, p1}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addCollection(Lcom/vividsolutions/jts/geom/GeometryCollection;)V

    goto :goto_0

    .line 124
    :cond_5
    instance-of v0, p1, Lcom/vividsolutions/jts/geom/MultiPolygon;

    if-eqz v0, :cond_6

    check-cast p1, Lcom/vividsolutions/jts/geom/MultiPolygon;

    invoke-direct {p0, p1}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addCollection(Lcom/vividsolutions/jts/geom/GeometryCollection;)V

    goto :goto_0

    .line 125
    :cond_6
    instance-of v0, p1, Lcom/vividsolutions/jts/geom/GeometryCollection;

    if-eqz v0, :cond_7

    check-cast p1, Lcom/vividsolutions/jts/geom/GeometryCollection;

    invoke-direct {p0, p1}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addCollection(Lcom/vividsolutions/jts/geom/GeometryCollection;)V

    :goto_0
    return-void

    .line 126
    :cond_7
    new-instance v0, Ljava/lang/UnsupportedOperationException;

    invoke-virtual {p1}, Ljava/lang/Object;->getClass()Ljava/lang/Class;

    move-result-object p1

    invoke-virtual {p1}, Ljava/lang/Class;->getName()Ljava/lang/String;

    move-result-object p1

    invoke-direct {v0, p1}, Ljava/lang/UnsupportedOperationException;-><init>(Ljava/lang/String;)V

    throw v0
.end method

.method private addCollection(Lcom/vividsolutions/jts/geom/GeometryCollection;)V
    .locals 2

    const/4 v0, 0x0

    .line 130
    :goto_0
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/GeometryCollection;->getNumGeometries()I

    move-result v1

    if-ge v0, v1, :cond_0

    .line 131
    invoke-virtual {p1, v0}, Lcom/vividsolutions/jts/geom/GeometryCollection;->getGeometryN(I)Lcom/vividsolutions/jts/geom/Geometry;

    move-result-object v1

    .line 132
    invoke-direct {p0, v1}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->add(Lcom/vividsolutions/jts/geom/Geometry;)V

    add-int/lit8 v0, v0, 0x1

    goto :goto_0

    :cond_0
    return-void
.end method

.method private addCurve([Lcom/vividsolutions/jts/geom/Coordinate;II)V
    .locals 4

    .line 106
    array-length v0, p1

    const/4 v1, 0x2

    if-ge v0, v1, :cond_0

    return-void

    .line 108
    :cond_0
    new-instance v0, Lcom/vividsolutions/jts/noding/SegmentString;

    new-instance v1, Lcom/vividsolutions/jts/geomgraph/Label;

    const/4 v2, 0x0

    const/4 v3, 0x1

    invoke-direct {v1, v2, v3, p2, p3}, Lcom/vividsolutions/jts/geomgraph/Label;-><init>(IIII)V

    invoke-direct {v0, p1, v1}, Lcom/vividsolutions/jts/noding/SegmentString;-><init>([Lcom/vividsolutions/jts/geom/Coordinate;Ljava/lang/Object;)V

    .line 110
    iget-object p1, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->curveList:Ljava/util/List;

    invoke-interface {p1, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    return-void
.end method

.method private addCurves(Ljava/util/List;II)V
    .locals 1

    .line 88
    invoke-interface {p1}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object p1

    :goto_0
    invoke-interface {p1}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-eqz v0, :cond_0

    .line 89
    invoke-interface {p1}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, [Lcom/vividsolutions/jts/geom/Coordinate;

    .line 90
    invoke-direct {p0, v0, p2, p3}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addCurve([Lcom/vividsolutions/jts/geom/Coordinate;II)V

    goto :goto_0

    :cond_0
    return-void
.end method

.method private addLineString(Lcom/vividsolutions/jts/geom/LineString;)V
    .locals 5

    .line 147
    iget-wide v0, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->distance:D

    const-wide/16 v2, 0x0

    cmpg-double v4, v0, v2

    if-gtz v4, :cond_0

    return-void

    .line 148
    :cond_0
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/LineString;->getCoordinates()[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object p1

    invoke-static {p1}, Lcom/vividsolutions/jts/geom/CoordinateArrays;->removeRepeatedPoints([Lcom/vividsolutions/jts/geom/Coordinate;)[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object p1

    .line 149
    iget-object v0, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->curveBuilder:Lcom/vividsolutions/jts/operation/buffer/OffsetCurveBuilder;

    iget-wide v1, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->distance:D

    invoke-virtual {v0, p1, v1, v2}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveBuilder;->getLineCurve([Lcom/vividsolutions/jts/geom/Coordinate;D)Ljava/util/List;

    move-result-object p1

    const/4 v0, 0x2

    const/4 v1, 0x0

    .line 150
    invoke-direct {p0, p1, v0, v1}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addCurves(Ljava/util/List;II)V

    return-void
.end method

.method private addPoint(Lcom/vividsolutions/jts/geom/Point;)V
    .locals 5

    .line 140
    iget-wide v0, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->distance:D

    const-wide/16 v2, 0x0

    cmpg-double v4, v0, v2

    if-gtz v4, :cond_0

    return-void

    .line 141
    :cond_0
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Point;->getCoordinates()[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object p1

    .line 142
    iget-object v0, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->curveBuilder:Lcom/vividsolutions/jts/operation/buffer/OffsetCurveBuilder;

    iget-wide v1, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->distance:D

    invoke-virtual {v0, p1, v1, v2}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveBuilder;->getLineCurve([Lcom/vividsolutions/jts/geom/Coordinate;D)Ljava/util/List;

    move-result-object p1

    const/4 v0, 0x2

    const/4 v1, 0x0

    .line 143
    invoke-direct {p0, p1, v0, v1}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addCurves(Ljava/util/List;II)V

    return-void
.end method

.method private addPolygon(Lcom/vividsolutions/jts/geom/Polygon;)V
    .locals 13

    .line 155
    iget-wide v0, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->distance:D

    const-wide/16 v2, 0x0

    cmpg-double v4, v0, v2

    if-gez v4, :cond_0

    neg-double v0, v0

    const/4 v4, 0x2

    goto :goto_0

    :cond_0
    const/4 v4, 0x1

    .line 162
    :goto_0
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Polygon;->getExteriorRing()Lcom/vividsolutions/jts/geom/LineString;

    move-result-object v5

    check-cast v5, Lcom/vividsolutions/jts/geom/LinearRing;

    .line 163
    invoke-virtual {v5}, Lcom/vividsolutions/jts/geom/LineString;->getCoordinates()[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object v6

    invoke-static {v6}, Lcom/vividsolutions/jts/geom/CoordinateArrays;->removeRepeatedPoints([Lcom/vividsolutions/jts/geom/Coordinate;)[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object v6

    .line 166
    iget-wide v7, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->distance:D

    cmpg-double v9, v7, v2

    if-gez v9, :cond_1

    invoke-direct {p0, v5, v7, v8}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->isErodedCompletely(Lcom/vividsolutions/jts/geom/LinearRing;D)Z

    move-result v5

    if-eqz v5, :cond_1

    return-void

    :cond_1
    const/4 v10, 0x2

    const/4 v11, 0x0

    move-object v5, p0

    move-wide v7, v0

    move v9, v4

    .line 169
    invoke-direct/range {v5 .. v11}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addPolygonRing([Lcom/vividsolutions/jts/geom/Coordinate;DIII)V

    const/4 v5, 0x0

    const/4 v12, 0x0

    .line 176
    :goto_1
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Polygon;->getNumInteriorRing()I

    move-result v5

    if-ge v12, v5, :cond_3

    .line 178
    invoke-virtual {p1, v12}, Lcom/vividsolutions/jts/geom/Polygon;->getInteriorRingN(I)Lcom/vividsolutions/jts/geom/LineString;

    move-result-object v5

    check-cast v5, Lcom/vividsolutions/jts/geom/LinearRing;

    .line 179
    invoke-virtual {v5}, Lcom/vividsolutions/jts/geom/LineString;->getCoordinates()[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object v6

    invoke-static {v6}, Lcom/vividsolutions/jts/geom/CoordinateArrays;->removeRepeatedPoints([Lcom/vividsolutions/jts/geom/Coordinate;)[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object v6

    .line 183
    iget-wide v7, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->distance:D

    cmpl-double v9, v7, v2

    if-lez v9, :cond_2

    neg-double v7, v7

    invoke-direct {p0, v5, v7, v8}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->isErodedCompletely(Lcom/vividsolutions/jts/geom/LinearRing;D)Z

    move-result v5

    if-eqz v5, :cond_2

    goto :goto_2

    .line 189
    :cond_2
    invoke-static {v4}, Lcom/vividsolutions/jts/geomgraph/Position;->opposite(I)I

    move-result v9

    const/4 v10, 0x0

    const/4 v11, 0x2

    move-object v5, p0

    move-wide v7, v0

    invoke-direct/range {v5 .. v11}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addPolygonRing([Lcom/vividsolutions/jts/geom/Coordinate;DIII)V

    :goto_2
    add-int/lit8 v12, v12, 0x1

    goto :goto_1

    :cond_3
    return-void
.end method

.method private addPolygonRing([Lcom/vividsolutions/jts/geom/Coordinate;DIII)V
    .locals 2

    .line 215
    iget-object v0, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->cga:Lcom/vividsolutions/jts/algorithm/CGAlgorithms;

    invoke-static {p1}, Lcom/vividsolutions/jts/algorithm/CGAlgorithms;->isCCW([Lcom/vividsolutions/jts/geom/Coordinate;)Z

    move-result v0

    if-eqz v0, :cond_0

    .line 218
    invoke-static {p4}, Lcom/vividsolutions/jts/geomgraph/Position;->opposite(I)I

    move-result p4

    move v1, p6

    move p6, p5

    move p5, v1

    .line 220
    :cond_0
    iget-object v0, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->curveBuilder:Lcom/vividsolutions/jts/operation/buffer/OffsetCurveBuilder;

    invoke-virtual {v0, p1, p4, p2, p3}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveBuilder;->getRingCurve([Lcom/vividsolutions/jts/geom/Coordinate;ID)Ljava/util/List;

    move-result-object p1

    .line 221
    invoke-direct {p0, p1, p5, p6}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->addCurves(Ljava/util/List;II)V

    return-void
.end method

.method private isErodedCompletely(Lcom/vividsolutions/jts/geom/LinearRing;D)Z
    .locals 8

    .line 235
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/LineString;->getCoordinates()[Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object v0

    .line 238
    array-length v1, v0

    const/4 v2, 0x1

    const/4 v3, 0x0

    const-wide/16 v4, 0x0

    const/4 v6, 0x4

    if-ge v1, v6, :cond_1

    cmpg-double p1, p2, v4

    if-gez p1, :cond_0

    goto :goto_0

    :cond_0
    const/4 v2, 0x0

    :goto_0
    return v2

    .line 243
    :cond_1
    array-length v1, v0

    if-ne v1, v6, :cond_2

    .line 244
    invoke-direct {p0, v0, p2, p3}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->isTriangleErodedCompletely([Lcom/vividsolutions/jts/geom/Coordinate;D)Z

    move-result p1

    return p1

    .line 247
    :cond_2
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Geometry;->getEnvelopeInternal()Lcom/vividsolutions/jts/geom/Envelope;

    move-result-object p1

    .line 248
    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Envelope;->getHeight()D

    move-result-wide v0

    invoke-virtual {p1}, Lcom/vividsolutions/jts/geom/Envelope;->getWidth()D

    move-result-wide v6

    invoke-static {v0, v1, v6, v7}, Ljava/lang/Math;->min(DD)D

    move-result-wide v0

    cmpg-double p1, p2, v4

    if-gez p1, :cond_3

    const-wide/high16 v4, 0x4000000000000000L    # 2.0

    .line 249
    invoke-static {p2, p3}, Ljava/lang/Math;->abs(D)D

    move-result-wide p1

    mul-double p1, p1, v4

    cmpl-double p3, p1, v0

    if-lez p3, :cond_3

    return v2

    :cond_3
    return v3
.end method

.method private isTriangleErodedCompletely([Lcom/vividsolutions/jts/geom/Coordinate;D)Z
    .locals 6

    .line 295
    new-instance v0, Lcom/vividsolutions/jts/geom/Triangle;

    const/4 v1, 0x0

    aget-object v2, p1, v1

    const/4 v3, 0x1

    aget-object v4, p1, v3

    const/4 v5, 0x2

    aget-object p1, p1, v5

    invoke-direct {v0, v2, v4, p1}, Lcom/vividsolutions/jts/geom/Triangle;-><init>(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/Coordinate;)V

    .line 296
    invoke-virtual {v0}, Lcom/vividsolutions/jts/geom/Triangle;->inCentre()Lcom/vividsolutions/jts/geom/Coordinate;

    move-result-object p1

    .line 297
    iget-object v2, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->cga:Lcom/vividsolutions/jts/algorithm/CGAlgorithms;

    iget-object v2, v0, Lcom/vividsolutions/jts/geom/Triangle;->p0:Lcom/vividsolutions/jts/geom/Coordinate;

    iget-object v0, v0, Lcom/vividsolutions/jts/geom/Triangle;->p1:Lcom/vividsolutions/jts/geom/Coordinate;

    invoke-static {p1, v2, v0}, Lcom/vividsolutions/jts/algorithm/CGAlgorithms;->distancePointLine(Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/Coordinate;Lcom/vividsolutions/jts/geom/Coordinate;)D

    move-result-wide v4

    .line 298
    invoke-static {p2, p3}, Ljava/lang/Math;->abs(D)D

    move-result-wide p1

    cmpg-double p3, v4, p1

    if-gez p3, :cond_0

    const/4 v1, 0x1

    :cond_0
    return v1
.end method


# virtual methods
.method public getCurves()Ljava/util/List;
    .locals 1

    .line 82
    iget-object v0, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->inputGeom:Lcom/vividsolutions/jts/geom/Geometry;

    invoke-direct {p0, v0}, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->add(Lcom/vividsolutions/jts/geom/Geometry;)V

    .line 83
    iget-object v0, p0, Lcom/vividsolutions/jts/operation/buffer/OffsetCurveSetBuilder;->curveList:Ljava/util/List;

    return-object v0
.end method
